//
//  NSDictionary+ServerResponse.m

#import "NSDictionary+ServerResponse.h"

static NSString *const kStatusCodeKey = @"status";
static NSString *const kMessageKey = @"message";
static NSString *const kDataKey = @"data";
static NSString *const kTimestampKey = @"timestamp";
static NSString *const kCursor = @"cursor";
static NSString *const kItems = @"items";

@implementation NSDictionary (ServerResponse)

- (NSInteger)statusCode
{
    return [[self numberForKey:kStatusCodeKey] integerValue];
}

- (NSString *)message
{
    NSString *message = [self stringForKey:kMessageKey];

    if (!message) {
        message = @"";
    }

    return message;
}

- (NSDictionary *)data
{
    return [self dictionaryForKey:kDataKey];
}

- (NSNumber *)timestamp
{
    return [self numberForKey:kTimestampKey];
}

- (NSString *)cursor
{
    return [self stringForKey:kCursor];
}

- (NSArray *)items
{
    return [self arrayForKey:kItems];
}

@end
